﻿using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;

namespace ACSTools.DataContracts
{
    [JsonObject]
    public class Device
    {
        public Device() { }

        [JsonProperty("deviceId")]
        public string deviceId { get; set; }

        [JsonProperty("subscriberCode")]
        public string subscriberCode { get; set; }

        //THIS

        [JsonProperty("oui")]
        public string oui { get; set; }

        [JsonProperty("sn")]
        public string sn { get; set; }

        //OR

        [JsonProperty("provisioningCode")]
        public string provisioningCode { get; set; }

        //OR

        [JsonProperty("cpProvisioningId")]
        public string cpProvisioningId { get; set; }

        [JsonProperty("manufacturer")]
        public string manufacturer { get; set; }

        [JsonProperty("friendlyManufacturerName")]
        public string friendlyManufacturerName { get; set; }

        [JsonProperty("deviceTypeId")]
        public string deviceTypeId { get; set; }

        [JsonProperty("friendlyName")]
        public string friendlyName { get; set; }

        [JsonProperty("softwareVersion")]
        public string softwareVersion { get; set; }

        [JsonProperty("disposition")]
        public string disposition { get; set; }

        [JsonProperty("excludeFromBulkOperation")]
        public bool excludeFromBulkOperation { get; set; }

        [JsonProperty("lastInform", ItemConverterType = typeof(IsoDateTimeConverter))]
        public DateTime lastInform { get; set; }

        [JsonProperty("firstInform", ItemConverterType = typeof(IsoDateTimeConverter))]
        public DateTime firstInform { get; set; }

        [JsonProperty("informCount")]
        public string informCount { get; set; }

        [JsonObject]
        public class label
        {
            public label() { }

            [JsonProperty("name")]
            public string name { get; set; }

            [JsonProperty("fgcolor")]
            public string fgcolor { get; set; }

            [JsonProperty("bgcolor")]
            public string bgcolor { get; set; }
        }

        [JsonProperty("labels")]
        public IList<label> labels { get; set; }

        [JsonObject]
        public class application
        {
            public application()
            { }

            [JsonObject]
            public class DTO
            {
                public DTO()
                { }

                [JsonObject]
                public class global
                {
                    public global()
                    { }

                    [JsonObject]
                    public class timeBlocking
                    {
                        public timeBlocking() { }

                        [JsonProperty("BlockURL")]
                        public string BlockURL { get; set; }
                    }

                    [JsonProperty("TimeBlocking")]
                    public timeBlocking TimeBlocking { get; set; }

                    [JsonObject]
                    public class deviceConfiguration
                    {
                        public deviceConfiguration()
                        { }

                        [JsonObject]
                        public class moduleConfiguration
                        {
                            public moduleConfiguration()
                            { }

                            [JsonObject]
                            public class stun
                            {
                                public stun() { }

                                [JsonProperty("MaximumKeepAlivePeriod")]
                                public string MaximumKeepAlivePeriod { get; set; }

                                [JsonProperty("ServerAddress")]
                                public string ServerAddress { get; set; }

                                [JsonProperty("ServerPort")]
                                public string ServerPort { get; set; }

                                [JsonProperty("MinimumKeepAlivePeriod")]
                                public string MinimumKeepAlivePeriod { get; set; }
                            }

                            [JsonProperty("STUN")]
                            public stun STUN { get; set; }

                            [JsonObject]
                            public class managementServer
                            {
                                public managementServer() { }

                                [JsonProperty("ConnectionRequesPassword")]
                                public string ConnectionRequesPassword { get; set; }

                                [JsonProperty("ConnectionRequestUsername")]
                                public string ConnectionRequestUsername { get; set; }

                                [JsonProperty("PeriodicInformInterval")]
                                public string PeriodicInformInterval { get; set; }
                            }

                            [JsonProperty("ManagementServer")]
                            public managementServer ManagementServer { get; set; }

                            [JsonObject]
                            public class accessControl
                            {
                                public accessControl() { }

                                [JsonProperty("SSH")]
                                public string SSH { get; set; }

                                [JsonProperty("ICMP")]
                                public string ICMP { get; set; }

                                [JsonProperty("HTTP")]
                                public string HTTP { get; set; }

                                [JsonProperty("TELNET")]
                                public string TELNET { get; set; }
                            }

                            [JsonProperty("AccessControl")]
                            public accessControl AccessControl { get; set; }

                            [JsonObject]
                            public class controlPanel
                            {
                                public controlPanel() { }

                                [JsonProperty("RedirectURL")]
                                public string RedirectURL { get; set; }
                            }

                            [JsonProperty("ControlPanel")]
                            public controlPanel ControlPanel { get; set; }

                            [JsonObject]
                            public class common
                            {
                                public common() { }

                                [JsonProperty("Enable")]
                                public string Enable { get; set; }

                                [JsonProperty("Type")]
                                public string Type { get; set; }
                            }

                            [JsonProperty("Common")]
                            public common Common { get; set; }
                        }

                        [JsonProperty("ModuleConfigurations")]
                        public Dictionary<string, moduleConfiguration> ModuleConfigurations { get; set; }
                    }

                    [JsonProperty("DeviceConfiguration")]
                    public deviceConfiguration DeviceConfiguration { get; set; }

                    [JsonObject]
                    public class contentFiltering
                    {
                        public contentFiltering()
                        { }

                        [JsonObject]
                        public class servers
                        {
                            public servers()
                            { }

                            [JsonObject]
                            public class url
                            {
                                public url() { }

                                [JsonProperty("URL")]
                                public string URL { get; set; }
                            }

                            [JsonProperty("Servers")]
                            public Dictionary<string, url> Servers { get; set; }

                            [JsonProperty("ID")]
                            public string ID { get; set; }

                            [JsonProperty("AllowNonRated")]
                            public string AllowNonRated { get; set; }

                            [JsonProperty("Blockhttp")]
                            public string Blockhttp { get; set; }
                        }

                        [JsonProperty("Servers")]
                        public Dictionary<string, servers> Servers { get; set; }

                        [JsonProperty("BlockURL")]
                        public string BlockURL { get; set; }

                        [JsonProperty("BlockOnServerDown")]
                        public string BlockOnServerDown { get; set; }
                    }

                    [JsonProperty("ContentFiltering")]
                    public contentFiltering ContentFiltering { get; set; }

                    [JsonObject]
                    public class timeZones
                    {
                        public timeZones()
                        { }

                        [JsonProperty("ZoneRules")]
                        public string ZoneRules { get; set; }

                        [JsonObject]
                        public class display
                        {
                            public display() { }

                            [JsonProperty("Description")]
                            public string Description { get; set; }
                        }

                        [JsonProperty("Display")]
                        public Dictionary<string, display> Display { get; set; }

                        [JsonProperty("Order")]
                        public string Order { get; set; }

                        [JsonProperty("TimeZone")]
                        public string TimeZone { get; set; }
                    }

                    [JsonProperty("TimeZones")]
                    public Dictionary<string, timeZones> TimeZones { get; set; }
                }

                [JsonProperty("Global")]
                public global Global { get; set; }

                [JsonObject]
                public class settings
                {
                    public settings()
                    { }

                    [JsonObject]
                    public class wanPPPConnection
                    {
                        public wanPPPConnection() { }

                        [JsonProperty("Username")]
                        public string Username { get; set; }

                        [JsonProperty("Password")]
                        public string Password { get; set; }
                    }

                    [JsonProperty("WANPPPConnections")]
                    public Dictionary<string, wanPPPConnection> WANPPPConnections { get; set; }

                    [JsonObject]
                    public class managementServerStatus
                    {
                        public managementServerStatus() { }

                        [JsonProperty("ConnectionRequestURL")]
                        public string ConnectionRequestURL { get; set; }

                        [JsonProperty("ConnectionRequestUsername")]
                        public string ConnectionRequestUsername { get; set; }

                        [JsonProperty("PeriodicInformInterval")]
                        public string PeriodicInformInterval { get; set; }
                    }

                    [JsonProperty("ManagementServerStatus")]
                    public managementServerStatus ManagementServerStatus { get; set; }

                    [JsonObject]
                    public class deviceStats
                    {
                        public deviceStats()
                        { }

                        [JsonObject]
                        public class wanInterface
                        {
                            public wanInterface()
                            { }

                            [JsonObject]
                            public class wanInterfaceData
                            {
                                public wanInterfaceData() { }

                                [JsonProperty("Packets")]
                                public string Packets { get; set; }

                                [JsonProperty("Bytes")]
                                public string Bytes { get; set; }
                            }

                            [JsonProperty("Ifref")]
                            public string Ifref { get; set; }

                            [JsonProperty("Receive")]
                            public wanInterfaceData Receive { get; set; }

                            [JsonProperty("Transmit")]
                            public wanInterfaceData Transmit { get; set; }
                        }

                        [JsonProperty("WANInterfaces")]
                        public Dictionary<string, wanInterface> WANInterfaces { get; set; }

                        [JsonObject]
                        public class dslErrors
                        {
                            public dslErrors()
                            { }

                            [JsonProperty("LinkRetrain")]
                            public string LinkRetrain { get; set; }

                            [JsonObject]
                            public class down
                            {
                                public down() { }

                                [JsonProperty("HEC")]
                                public string HEC { get; set; }

                                [JsonProperty("CRC")]
                                public string CRC { get; set; }

                                [JsonProperty("SevereSeconds")]
                                public string SevereSeconds { get; set; }

                                [JsonProperty("Seconds")]
                                public string Seconds { get; set; }

                                [JsonProperty("FEC")]
                                public string FEC { get; set; }

                                [JsonProperty("Blocks")]
                                public string Blocks { get; set; }
                            }

                            [JsonProperty("Down")]
                            public down Down { get; set; }

                            [JsonObject]
                            public class up
                            {
                                public up() { }

                                [JsonProperty("CRC")]
                                public string CRC { get; set; }

                                [JsonProperty("HEC")]
                                public string HEC { get; set; }

                                [JsonProperty("FEC")]
                                public string FEC { get; set; }

                                [JsonProperty("Blocks")]
                                public string Blocks { get; set; }
                            }

                            [JsonProperty("Up")]
                            public up Up { get; set; }

                            [JsonProperty("InitTimeouts")]
                            public string InitTimeouts { get; set; }

                            [JsonProperty("Init")]
                            public string Init { get; set; }

                            [JsonProperty("CellDelin")]
                            public string CellDelin { get; set; }

                            [JsonProperty("LossOfFraming")]
                            public string LossOfFraming { get; set; }
                        }

                        [JsonProperty("DSLErrors")]
                        public dslErrors DSLErrors { get; set; }
                    }

                    [JsonProperty("DeviceStats")]
                    public deviceStats DeviceStats { get; set; }

                    [JsonObject]
                    public class deviceInfo
                    {
                        public deviceInfo()
                        { }

                        [JsonProperty("Uptime")]
                        public string Uptime { get; set; }

                        [JsonObject]
                        public class dsl
                        {
                            public dsl() { }

                            [JsonProperty("SNRDown")]
                            public string SNRDown { get; set; }

                            [JsonProperty("MaxRateUp")]
                            public string MaxRateUp { get; set; }

                            [JsonProperty("MaxBitRateDown")]
                            public string MaxBitRateDown { get; set; }

                            [JsonProperty("PowerUp")]
                            public string PowerUp { get; set; }

                            [JsonProperty("MaxBitRateUp")]
                            public string MaxBitRateUp { get; set; }

                            [JsonProperty("AttenuationDown")]
                            public string AttenuationDown { get; set; }

                            [JsonProperty("MaxRateDown")]
                            public string MaxRateDown { get; set; }

                            [JsonProperty("CurrentRateUp")]
                            public string CurrentRateUp { get; set; }

                            [JsonProperty("ThroughputDown")]
                            public string ThroughputDown { get; set; }

                            [JsonProperty("SNRUp")]
                            public string SNRUp { get; set; }

                            [JsonProperty("PowerDown")]
                            public string PowerDown { get; set; }

                            [JsonProperty("AttenuationUp")]
                            public string AttenuationUp { get; set; }

                            [JsonProperty("CurrentRateDown")]
                            public string CurrentRateDown { get; set; }

                            [JsonProperty("ThroughputUp")]
                            public string ThroughputUp { get; set; }
                        }

                        [JsonProperty("DSL")]
                        public dsl DSL { get; set; }
                    }

                    [JsonProperty("DeviceInfo")]
                    public deviceInfo DeviceInfo { get; set; }

                    [JsonObject]
                    public class wanDevices
                    {
                        public wanDevices() { }

                        [JsonProperty("ActiveWanDevice")]
                        public string ActiveWanDevice { get; set; }

                        [JsonProperty("WANType")]
                        public string WANType { get; set; }
                    }

                    [JsonProperty("WANDevices")]
                    public wanDevices WANDevices { get; set; }

                    [JsonObject]
                    public class wanInterfaces
                    {
                        public wanInterfaces()
                        { }

                        [JsonObject]
                        public class wanInterface
                        {
                            public wanInterface() { }

                            [JsonProperty("AccessType")]
                            public string AccessType { get; set; }

                            [JsonProperty("AddressingType")]
                            public string AddressingType { get; set; }

                            [JsonProperty("TR069Path")]
                            public string TR069Path { get; set; }

                            [JsonProperty("LinkAddress")]
                            public string LinkAddress { get; set; }

                            [JsonProperty("Ifref")]
                            public string Ifref { get; set; }

                            [JsonProperty("Id")]
                            public string Id { get; set; }

                            [JsonProperty("ConnectionType")]
                            public string ConnectionType { get; set; }

                            [JsonProperty("ExternalIPAddress")]
                            public string ExternalIPAddress { get; set; }
                        }

                        [JsonProperty("Interfaces")]
                        public Dictionary<string, wanInterface> Interfaces { get; set; }

                        [JsonProperty("DefaultPort")]
                        public string DefaultPort { get; set; }

                        [JsonProperty("DefaultInterface")]
                        public string DefaultInterface { get; set; }
                    }

                    [JsonProperty("WANInterfaces")]
                    public wanInterfaces WANInterfaces { get; set; }
                }

                [JsonProperty("Settings")]
                public settings Settings { get; set; }
            }

            [JsonProperty("dto")]
            public DTO dto { get; set; }
        }

        [JsonProperty("applications")]
        public Dictionary<string, application> applications { get; set; }

        [JsonObject]
        public class actionsLog
        {
            [JsonProperty("queuedRunId")]
            public string queuedRunId { get; set; }

            [JsonProperty("name")]
            public string name { get; set; }

            [JsonProperty("actorName")]
            public string actorName { get; set; }

            [JsonProperty("runOn")]
            public string runOn { get; set; }

            [JsonProperty("state")]
            public string state { get; set; }

            [JsonObject]
            public class logs
            {
                [JsonProperty("timestamp")]
                public string timestamp { get; set; }

                [JsonProperty("message")]
                public string message { get; set; }

                [JsonProperty("status")]
                public string status { get; set; }
            }

            [JsonProperty("log")]
            public IList<logs> log { get; set; }
        }

        [JsonProperty("actionLog")]
        public IList<actionsLog> actionLog { get; set; }

        [JsonObject]
        public class queuedAction
        {
            public queuedAction()
            { }

            [JsonProperty("revision")]
            public string revision { get; set; }

            [JsonProperty("solicit")]
            public bool solicit { get; set; }

            [JsonObject]
            public class script
            {
                [JsonProperty("queuedRunId")]
                public string deviceId { get; set; }

                [JsonProperty("scriptCode")]
                public string scriptCode { get; set; }

                [JsonProperty("status")]
                public string status { get; set; }

                [JsonObject]
                public class parameter
                {
                    [JsonProperty("name")]
                    public string name { get; set; }

                    [JsonProperty("value")]
                    public string value { get; set; }
                }

                [JsonProperty("parameters")]
                public IList<parameter> parameters { get; set; }
            }

            [JsonProperty("scripts")]
            public IList<script> scripts { get; set; }

            [JsonObject]
            public class application
            {
                public application() { }

                [JsonProperty("pendingSync")]
                public bool pendingSync { get; set; }

                [JsonProperty("dataOwner")]
                public string dataOwner { get; set; }

                [JsonProperty("needsInitialization")]
                public bool needsInitialization { get; set; }
            }

            [JsonProperty("applications")]
            public Dictionary<string, application> applications { get; set; }

            [JsonObject]
            public class service
            {
                public service() { }

                [JsonProperty("canToggleStatus")]
                public bool canToggleStatus { get; set; }

                [JsonProperty("status")]
                public string status { get; set; }
            }

            [JsonProperty("services")]
            public Dictionary<string, service> services { get; set; }
        }

        [JsonProperty("queuedActions")]
        public queuedAction queuedActions { get; set; }
    }
}
